using System;
using System.Windows;
using System.Windows.Data;
namespace Microsoft.Phone.Controls
{
	internal class BindingEvaluator<T> : FrameworkElement
	{
		private Binding _binding;
		public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(T), typeof(BindingEvaluator<T>), new PropertyMetadata(default(T)));
		public T Value
		{
			get
			{
				return (T)((object)base.GetValue(BindingEvaluator<T>.ValueProperty));
			}
			set
			{
				base.SetValue(BindingEvaluator<T>.ValueProperty, value);
			}
		}
		public Binding ValueBinding
		{
			get
			{
				return this._binding;
			}
			set
			{
				this._binding = value;
				base.SetBinding(BindingEvaluator<T>.ValueProperty, this._binding);
			}
		}
		public BindingEvaluator()
		{
		}
		public BindingEvaluator(Binding binding)
		{
			base.SetBinding(BindingEvaluator<T>.ValueProperty, binding);
		}
		public void ClearDataContext()
		{
			base.set_DataContext(null);
		}
		public T GetDynamicValue(object o, bool clearDataContext)
		{
			base.set_DataContext(o);
			T value = this.Value;
			if (clearDataContext)
			{
				base.set_DataContext(null);
			}
			return value;
		}
		public T GetDynamicValue(object o)
		{
			base.set_DataContext(o);
			return this.Value;
		}
	}
}
